package stringbuilder01;
/**
 * StringBuilder链式编程
 */
public class StringBuilderDemo05 {
    public static void main(String[] args) {
        //method01();
        //StringBuilder stringBuilder = new StringBuilder();
        //StringBuilder stringBuilder1 = stringBuilder.append(5).append('s').append("abc");
        //System.out.println(stringBuilder1);
        String str = new StringBuilder().append(5).append("abc").append('x').toString();
        System.out.println(str);
    }

    private static void method01() {
        StringBuilder stringBuilder = new StringBuilder();

        //stringBuilder1,stringBuilder2,stringBuilder3都指向StringBuilder对象,就是最开始的容器
        //stringBuilder1 = stringBuilder2 = stringBuilder3
        StringBuilder stringBuilder1 = stringBuilder.append(7);
        StringBuilder stringBuilder2 = stringBuilder1.append("def");
        StringBuilder stringBuilder3 = stringBuilder2.append(6);
        System.out.println(stringBuilder1 == stringBuilder2);//true
        System.out.println(stringBuilder2 == stringBuilder3);//true
        System.out.println(stringBuilder1 == stringBuilder3);//true
    }
}
